package com.chixing.day05_oop;

public class AccountTest2 {
    public static void main(String[] args) {
        CreditAccount ca1 = new CreditAccount();


        //父类 引用子类对象
        //子类类型 / 父类类型 = new 子类（）;
        Account ca2 = new CreditAccount();

        byte b = 10;
        int i = b;

        Account acc = new Account();
        //CreditAccount ca3 = (CreditAccount) new Account();//父类对象 强制转换成子类对象
        CreditAccount ca4 = (CreditAccount) ca2;

        //为了避免强制转换出异常，在强转之前，先进行判断
        /*if (ca3 instanceof CreditAccount){
            ca3 = (CreditAccount) new Account();
        }*/

        //class Bank{}

        SavingAccount sa1 = new SavingAccount();
        sa1.depoist(5);//运行子类depoist的方法

        //多态
        Account sa2 = new SavingAccount();//父类引用子类对象
        sa2.depoist(5);//运行子类depoist的方法

    }
}
